<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul{list-style: none;display: flex;}
        li{width:100px;height:100px;background:aquamarine;margin: 0 10px;}
    </style>
    <script type="text/javascript">
        window.onload = function(){
            var li = document.getElementsByTagName('li')
            var btn = document.getElementById('btn')
            btn.onclick = function(){
                console.log(1)
                for(var i = 0;i<li.length;i++){
                    li[i].style.backgroundColor = 'red'
                }
            }
        }
    </script>
</head>
<body>
<button id="btn">点击变色</button>
<ul>
    <li></li>
    <li></li>
    <li></li>
</ul>
</body>
</html>